namespace Chaotic.DataBase.DataAccess
{
	[Serializable]
	public class SqlStruct
	{
		private string? _mSqlString;

		private ParamField[] _mParamFields;

		public string? SqlString
		{
			get => _mSqlString;
            set
			{
				if (PersistenceProperty.DatabaseType == DatabaseType.MSSQLServer || PersistenceProperty.DatabaseType == DatabaseType.DB2)
				{
					_mSqlString = value?.Replace(":", "@");
				}
				else
				{
					_mSqlString = value?.Replace("@", ":");
				}
			}
		}

		public ParamField[] ParamFields
		{
			get => _mParamFields;
            set => _mParamFields = value;
        }

		public SqlStruct(string strSql, ParamField[] paramField)
		{
			if (PersistenceProperty.DatabaseType == DatabaseType.MSSQLServer || PersistenceProperty.DatabaseType == DatabaseType.DB2)
			{
				_mSqlString = strSql.Replace(":", "@");
				_mParamFields = paramField;
			}
			else
			{
				_mSqlString = strSql.Replace("@", ":");
				_mParamFields = paramField;
			}
		}
	}
}